package toy.keli.edic.data.model

import android.graphics.BitmapFactory
import android.net.Uri
import androidx.test.ext.junit.rules.ActivityScenarioRule
import com.google.mlkit.vision.common.InputImage
import toy.keli.edic.util.ActivityRun
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import toy.keli.edic.data.parse.Image2Text
import toy.keli.edic.util.MediaUtil
import java.io.File

class ArticleTest {
    @Before
    fun setUp() {
        val ct = androidx.test.InstrumentationRegistry.getTargetContext()
        ActivityRun.setConText(ct)
    }
    @Test
    fun hasIco() {

        val inputStream = ActivityRun.context.assets.open("aa.jpg")
        val bmap = BitmapFactory.decodeStream(inputStream)

//        val bmap = BitmapFactory.decodeFile("/storage/emulated/0/DCIM/test/aa.jpg")
        val img = InputImage.fromBitmap(bmap,0)
        val textToRead = Image2Text.convert(img)
//        var uri = MediaUtil.getImageUriByPath(ActivityRun.context,"/storage/emulated/0/DCIM/test/aa.jpg")
//        Article.addByImage(0, uri!!){
//
//        }
//        Article(1) {
//            if(hasIco()){
//                getIco()
//            }
//        }
        System.out.print(textToRead)
        assert(textToRead.size>2)
    }

}